package com.along.framework.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.along.framework.utils.Struts2Util;
import com.opensymphony.xwork2.ActionSupport;

public class BaseAction extends ActionSupport {
	
	
	//让子类拥有日志记录的能力
	protected  Logger log=LoggerFactory.getLogger(this.getClass());
	
	/**
	 * 取得HttpSession的简化方法.
	 */
	public  HttpSession getSession() {
		return ServletActionContext.getRequest().getSession();
	}

	/**
	 * 取得HttpRequest的简化方法.
	 */
	public  HttpServletRequest getRequest() {
		return ServletActionContext.getRequest();
	}

	/**
	 * 取得HttpResponse的简化方法.
	 */
	public  HttpServletResponse getResponse() {
		return ServletActionContext.getResponse();
	}

	/**
	 * 取得Request Parameter的简化方法.
	 */
	public  String getParameter(String name) {
		return getRequest().getParameter(name);
	}
	
	public String getBasePath()
	{
		String path = getRequest().getContextPath();
		return getRequest().getScheme()+"://"+getRequest().getServerName()+":"+getRequest().getServerPort()+path+"/";
	}
	

	
	/**
	 * 提供获取request,response,session的能力;向客户端返还多种数据格式的辅助方法
	 */
	protected static Struts2Util struts2Util;
}
